package o;

import android.text.TextUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public class ezq extends eui {
    private static ezq ˊ = null;

    private ezq() {
        super("game_login_flag");
    }

    public static synchronized ezq ˏ() {
        ezq o_ezq;
        synchronized (ezq.class) {
            if (ˊ == null) {
                ˊ = new ezq();
            }
            o_ezq = ˊ;
        }
        return o_ezq;
    }

    public void ˏ(int i, String str, String str2, String str3) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            Logger.e("GameLoginSP", "saveGameLoginUserId userid or defaultUserId is null.");
            return;
        }
        switch (i) {
            case 1:
                ˏ().ˏ("game_login_userid_" + str3, str + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + str2);
                return;
            case 2:
                ˏ().ˏ("h5game_login_userid_" + str3, str + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + str2);
                return;
            default:
                Logger.e("GameLoginSP", "saveGameLoginUserId type unknow:" + i);
                return;
        }
    }

    private Map<String, String> ॱ(int i, String str) {
        Map<String, String> hashMap = new HashMap();
        if (TextUtils.isEmpty(str)) {
            Logger.e("GameLoginSP", "getGameLoginUserId gameKey is null.");
        } else {
            Object obj = "";
            switch (i) {
                case 1:
                    obj = ˏ().ˊ("game_login_userid_" + str, "");
                    break;
                case 2:
                    obj = ˏ().ˊ("h5game_login_userid_" + str, "");
                    break;
                default:
                    Logger.e("GameLoginSP", "getGameLoginUserId type unknow:" + i);
                    break;
            }
            if (TextUtils.isEmpty(obj)) {
                Logger.ˏ("GameLoginSP", "GameLoginUserId is null:" + str);
            } else {
                String[] split = obj.split("\\|");
                if (split.length == 2) {
                    hashMap.put("userId", split[0]);
                    hashMap.put("default_userId", split[1]);
                }
            }
        }
        return hashMap;
    }

    public String ˊ(String str) {
        Map ॱ = ॱ(1, str);
        String str2 = (String) ॱ.get("userId");
        String str3 = (String) ॱ.get("default_userId");
        if (str3 == null || !str3.equals(str2)) {
            return str2;
        }
        return null;
    }

    public String ˏ(String str) {
        return (String) ॱ(1, str).get("default_userId");
    }

    public String ˎ(String str) {
        return (String) ॱ(1, str).get("userId");
    }

    public String ˊ(String str, String str2) {
        try {
            String ॱ = ॱ(str, str2);
            if (ॱ == null || ॱ.equals(str2)) {
                return str2;
            }
            String[] split = new String(dnk.ˎ(ॱ), StandardCharsets.UTF_8).split("\\|");
            String ˋ;
            if (split.length <= 1) {
                ˋ = bfh.ˏ().ˋ(ॱ, ˊ());
                if (ʻ(ˋ, ॱ)) {
                    ˏ(str, ˋ);
                }
                return ˋ;
            }
            ॱ = split[0];
            String str3 = split[1];
            ˋ = evh.ˊ().ॱ(ॱ, str3);
            if (!ʻ(ˋ, ॱ)) {
                ˋ = bfh.ˏ().ˋ(ॱ, str3);
                if (ʻ(ˋ, ॱ)) {
                    ˏ(str, ˋ);
                }
            }
            return ˋ;
        } catch (Exception e) {
            Logger.e("GameLoginSP", "getSecretString exception");
            return str2;
        }
    }

    public long ˎ(String str, String str2) {
        if (dof.ॱ(str2) || dof.ॱ(str)) {
            return 0;
        }
        String ॱ = ॱ(str, "");
        if (dof.ॱ(ॱ)) {
            return 0;
        }
        String[] split = ॱ.split("\\|");
        if (split.length <= 1) {
            return 0;
        }
        Object ˎ = eux.ˎ(split[0]);
        if (TextUtils.isEmpty(ˎ)) {
            return 0;
        }
        try {
            long parseLong = Long.parseLong(split[1]);
            if (ˎ.equals(str2)) {
                return parseLong;
            }
            return 0;
        } catch (NumberFormatException e) {
            return 0;
        }
    }

    public void ˏ(String str, long j, String str2) {
        if (!dof.ॱ(str2) && !dof.ॱ(str)) {
            ˋ(str, eux.ˊ(str2) + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + j);
        }
    }

    private boolean ʻ(String str, String str2) {
        if (str == null || str.equals(str2)) {
            return false;
        }
        return true;
    }
}
